Repository navigation
Conversation
15dae73 to
d25a231
Compare
…e method in ModerationUtils;
| boolean isFirsttime = | ||
| actionsStore.getActionsByTargetAscending(guild.getIdLong(), target.getIdLong()) | ||
| .stream() | ||
| .noneMatch(action -> action.actionType() == ModerationAction.QUARANTINE); |
There was a problem hiding this comment.
Use findLastActionAgainstTargetByType and rename isFirsttime to isFirstTime
| boolean isFirsttime = | |
| actionsStore.getActionsByTargetAscending(guild.getIdLong(), target.getIdLong()) | |
| .stream() | |
| .noneMatch(action -> action.actionType() == ModerationAction.QUARANTINE); | |
| boolean isFirstTime = actionsStore | |
| .findLastActionAgainstTargetByType(guild.getIdLong(), target.getIdLong(), | |
| ModerationAction.QUARANTINE) | |
| .isEmpty(); |
| final String guildId = guild.getId(); | ||
| final String targetId = target.getId(); | ||
|
|
||
| if (!isFirsttime) { |
There was a problem hiding this comment.
| if (!isFirsttime) { | |
| if (!isFirstTime) { |
Corresponding to above
| Member member = Objects.requireNonNull(event.getMember()); | ||
|
|
||
| if (!Guilds.hasMemberRole(member, ModerationUtils.getIsQuarantinedRolePredicate(config))) { | ||
| event.reply("You are not quarantined anymore!").setEphemeral(true).queue(); |
There was a problem hiding this comment.
| event.reply("You are not quarantined anymore!").setEphemeral(true).queue(); | |
| event.reply("You are not quarantined anymore!").setEphemeral(true).queue(); |
| if (member == null) { | ||
| logger.warn(LogMarkers.SENSITIVE, | ||
| "scam message detected from a user that is not a member of the guild '{}'.", | ||
| guild.getId()); | ||
| return; | ||
| } |
There was a problem hiding this comment.
The only channels that are read are TextChannel's (a MessageChannel specifically for Guilds), that said if the user is not a Member of the guild we would have a shitton of NPE's before we arrive at this point. See ScamBlocker:142
There was a problem hiding this comment.
What do you suggest to do instead ?
There was a problem hiding this comment.
I forgot to say that this can just be removed, it just can't happen
There was a problem hiding this comment.
So that means, regardless the JDA stuff, we remove the check on a nullable getter here?
There was a problem hiding this comment.
You can replace it with Objects.requireNonNull(member) or just do no checks at all
|
could u please add to ur PR description a description of what u changed in the code and how. so we can better review it? like, which parts are new code, what has been moved from where to where? that kind of stuff |
Tais993
left a comment
There was a problem hiding this comment.
Everything else looks good, genuinely the only thing lol
| private void quarantineAuthor(Guild guild, Member author, SelfUser bot) { | ||
| String reason = "User posted scam that was automatically detected"; | ||
| Guild guild = event.getGuild(); | ||
| Member member = event.getMember(); |
There was a problem hiding this comment.
| Member member = event.getMember(); | |
| Member member = Objects.requireNonNull(event.getMember()); |
A bit nitpicky but do it here instead of during the method call
… at the local variable definition
b5f67ba to
0b6e905
Compare
|



When a user is quarantined, the bot posts a message in the #quarantine-zone channel that pings them and offers an "Unquarantine me" button. Users who regained control of their account can get back in without a mod.
demo-qss.mp4
New
ModerationUtils#quarantine:QuarantineCommand#onButtonClickhandles the button:UNQUARANTINEin the store with the bot as author, and disables the button.quarantineChannelPattern, used to find the quarantine channelMoved
ModerationUtils#quarantine. It used to be duplicated in 2 places:QuarantineCommand#quarantineUser(private method, removed)ScamBlocker#quarantineAuthor(now just callsModerationUtils#quarantine)QuarantineandScamBlockercommands therefore all work the same way: the self-service message is sent for every quarantine operation. The behaviour of the quarantine itself is unchanged: same action stored, same role, same reason.How the button is wired
Supplier<String>, sinceModerationUtilsis static and can't generate component IDs.QuarantineCommandgenerates it itself.ScamBlockeruses aComponentIdInteractorpointing at the quarantine command's name, so clicks from both paths end up inQuarantineCommand#onButtonClick.COMMAND_NAMEis now public for this.Lifespan.PERMANENT, because users may come back weeks later.Untouched
UnquarantineCommandand its mod permission checks./quarantine.Closes #1594